package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.servlet.http.HttpServletRequest;
import java.util.Map;

import static org.springframework.web.context.ContextLoader.*;

@Controller
@RequestMapping(value = "router")
public class RouterController {

    @Autowired
    private ApplicationContext context;

    @RequestMapping(value = "excel")
    @ResponseBody
    public Map<String, Object> excel(HttpServletRequest request, String invokeName) {
        /* WebApplicationContext webApplicationContext = getCurrentWebApplicationContext(); */
        System.err.println("Router Run");
        ExcelInterface excelObj = (ExcelInterface)context.getBean(invokeName);
        return excelObj.excel();
    }

}
